package com.tencent.wxcloudrun.service.impl;

import com.tencent.wxcloudrun.dao.UserMapper;
import com.tencent.wxcloudrun.model.User;
import com.tencent.wxcloudrun.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("userService")
public class UserServiceImpl implements UserService {

    @Autowired
    private  UserMapper userMapper;

    /**
     * 查询所有用户名方法,给前端来判断用户名注册时是否重复
     * @return
     */
    @Override
    public List<String> findAllAccount() {
        return userMapper.selectAllAcoount();
    }


    /**
     * 用户注册的方法
     * @param user 注册的用户的实例
     * @return
     */
    @Override
    public int addRegistUser(User user) {
        return userMapper.insertRegistUser(user);
    }

    /**
     * 用户登录的方法
     * @param account 账号
     * @param password 密码
     * @return 匹配到的用户实例
     */
    @Override
    public User login(String account, String password) {
        return userMapper.login(account, password);
    }
}
